package edu.ufl.cise.cop5555.sp12;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;

import edu.ufl.cise.cop5555.sp12.Scanner;
import edu.ufl.cise.cop5555.sp12.Parser;
import edu.ufl.cise.cop5555.sp12.ast.AST;
import edu.ufl.cise.cop5555.sp12.ast.ASTVisitor;
import edu.ufl.cise.cop5555.sp12.ast.Declaration;
import edu.ufl.cise.cop5555.sp12.ast.ToStringVisitor;
import edu.ufl.cise.cop5555.sp12.ast.Type;
import edu.ufl.cise.cop5555.sp12.context.ContextCheckVisitor;
import edu.ufl.cise.cop5555.sp12.context.SymbolTable;
import edu.ufl.cise.cop5555.sp12.TokenStream; 


public class main{
	
	public static void main(String args[])
	{
	/*	BufferedReader br= null;
		try {
			br  = new BufferedReader(new FileReader("new.txt"));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		TokenStream tokenStream = new TokenStream("prog y x[x * (4)]=-y[4+-y]; gorp");
		Scanner s = new Scanner(tokenStream);
		s.scan(); //create the Token array
		Parser parser = new Parser(tokenStream);
		try {
			AST ast = parser.parse();
			ToStringVisitor pv = new ToStringVisitor();
			 ast.visit(pv,""); 
			 String st = pv.getString(); 
			 System.out.println(st);
			//System.out.println("Successful");
		} catch (SyntaxException e) {
			// TODO Auto-generated catch block
		
			e.printStackTrace();
		}
		//Exception e = parser.parse();
 catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
		
		
	/*	//Symbol Table test
		SymbolTable s = new SymbolTable();
		Declaration d = null;
		s.enterScope();
		s.insert("a", d);
		s.enterScope();
		s.insert("a", d);
		s.enterScope();
		s.insert("a", d);
		
		s.lookup("a");
		s.display();
		
	*/	
		TokenStream stream = new TokenStream("prog Test1 boolean x; int y; do(x< == y) od; gorp");
		Scanner sc = new Scanner(stream);
		sc.scan(); //create the Token array   
	    Parser parser = new Parser(stream); 
	       
		AST ast = null;
		try {
			ast = parser.parse();
		} catch (SyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} //get AST from project 3
		ASTVisitor contextChecker = new ContextCheckVisitor();
		try {
			ast.visit(contextChecker,null);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}
}